package com.slz3.business.module.afterSaleManagement.aftWorkOrder.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.afterSaleManagement.aftWorkOrder.domain.AftWorkOrder;
import com.slz3.business.module.afterSaleManagement.aftWorkOrder.domain.AftWorkOrderFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class AftWorkOrderTransactionalServiceImpl implements AftWorkOrderTransactionalService {

    @Override
    public AftWorkOrder modify(AftWorkOrder aftWorkOrderNew) {
        Repositorys.aftWorkOrder.test();
        Repositorys.aftWorkOrder.save(AftWorkOrderFactory.initBaseFields());
        System.err.println(1 / 0);
        aftWorkOrderNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.aftWorkOrder.saveAndFlush(aftWorkOrderNew);
    }

    @Override
    public List<AftWorkOrder> batchModify(List<AftWorkOrder> aftWorkOrderList) {
        return Repositorys.aftWorkOrder.saveAll(aftWorkOrderList);
    }
}
